using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

public class Map : MonoBehaviour
{
    // Start is called before the first frame update
    void Awake()
    {
        Instance = this;
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public Tilemap tilemap;

    public static Map Instance;
    public bool IsCanWalk(Vector3 pos)
    {
        var vec = new Vector3Int(Mathf.RoundToInt(pos.x), Mathf.RoundToInt(pos.y), (int)pos.z);
        var tile = tilemap.GetTile(vec);
        if (tile != null)
        {
            if (MapMix.IsBarrier(tile.name))
            {
                //Debug.Log(vec + " from:" + pos + " <color=red>tile.name</color>:" + tile.name);
                Debug.Log(vec + " from:" + pos + " <color=red>不可穿越</color>:" + tile.name);
                return false;
            }

            //Debug.Log(vec + " from:" + pos + " tile.name:" + tile.name);
            return true;
        }
        else
        {
            return false;
        }
    }
}
